package com.ybdz.scanner.utils;

import android.app.Activity;
import android.util.Log;

import com.ybdz.scanner.activity.LoginActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by gs on 2018/3/29.
 */

public class ActivityCollector {
    public static List<Activity> activities = new ArrayList<>();

    public static void addActivity(Activity activity){

        if (!String.valueOf(activity).contains("LoginActivity")){
            if (!activities.contains(activity)){
                activities.add(activity);
            }
            Log.i("Activity包含","不包含LoginActivity");
        }else {
            Log.i("Activity包含","包含LoginActivity");
        }

    }

    public static void removeActivity(Activity activity){
        activities.remove(activity);
    }

    public static void finishAll(){
        for(Activity activity : activities){
            if(!activity.isFinishing()){
                activity.finish();
            }
        }
    }
}
